package selectionSort;

import w3_c1_array.Array;

public class Student implements Comparable<Student> {
    String name;
    int score;
    public Student(String name, int score){
        this.name = name;
        this.score = score;
    }

    @Override
    public  boolean equals(Object another){
        if (another == this)
            return  true;
        else if (another == null)
            return  false;
        else if(this.getClass() != another.getClass())
            return false;
        Student tmp = (Student) another;
        return tmp.name.toLowerCase().equals(this.name.toLowerCase());
    }

    @Override
    public int compareTo(Student another) {
//        if (this.score - another.score > 0)
//            return  1;
//        else if(this.score - another.score < 0)
//            return -1;
//        return 0;
        return this.score - another.score;
    }


    @Override
    public String toString(){
       return String.format("Student(name: %s, score: %d)",this.name,this.score);
    }

    public static void main(String[] args) {
        Array<Student> students = new Array<>();
        students.addLast(new Student("Alice", 88));
        students.addLast(new Student("Bob", 100));
        students.addLast(new Student("Charles", 10));

        System.out.println(students);

    }
}
